package autoz.czt.test;

import java.util.List;

import net.sourceforge.czt.parser.util.CztError;
import net.sourceforge.czt.session.CommandException;
import autoz.core.problems.UmlProblem;
import autoz.czt.launching.CZTEngine;

public class CZTTestSpec {
	
	public static void main(String[] args) throws CommandException{
		String zooToolkit = "/local/d0p6/jw/Projects/autoz/doc/ExampleUML/ZOO_toolkit.tex";
		String specPath = "/local/d0p6/jw/Projects/autoz/doc/ExampleUML/gen.tex";
		String zooToolkitMac = "/Users/jimmy/Documents/Projects/autozmarkii/doc/ExampleUML/ZOO_toolkit.tex";
		String specPathMac = "/Users/jimmy/Documents/Projects/autozmarkii/doc/ExampleUML/gen.tex";

		validateSpec(specPathMac);
	}

	public static void validateSpec(String file) throws CommandException{
		CZTEngine engine = new CZTEngine(file);
		
		// Parse
		List<CztError> parseErrors = engine.parse();
		if (parseErrors != null && !parseErrors.isEmpty()){
			for (CztError e : parseErrors){
				System.out.println("pe:"+e);
			}
			return;
		}
		
		// Type check
		List<UmlProblem> typecheckErrors = engine.typecheck();
		for (UmlProblem problem : typecheckErrors){
			System.out.println(problem.getSchemaLocation() + ": "+problem.getProblem() + ": " + problem.getZLineNumber());
		}
		System.out.println("Complete.");
	}
	
}
